Skip to content

Handle "Execution context was destroyed" #3194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

jasonchuanet
Copy link

One of my watches (with browser steps) stopped working due to navigation errors. Ignoring the error and continuing resolves the issue and didn't break anything in my testing.
Not a new feature, just improved error handling.

@dgtlmoon
Copy link
Owner

hmm any way to test this? got an example URL?

@dgtlmoon
Copy link
Owner

dgtlmoon commented Jun 3, 2025

2025-06-03 09:00:10.024 | DEBUG | changedetectionio.blueprint.browser_steps.browser_steps:get_current_state:476 - Execution context was destroyed, most likely because of navigation, continuing...

(this is added)

2025-06-03 09:00:10.043 | ERROR | changedetectionio.model.Watch:save_screenshot:578 - Screenshot save called but screenshot was not set!!

So your fix definitely helps, but it still cant get the screenshot after that..

@dgtlmoon
Copy link
Owner

dgtlmoon commented Jun 3, 2025

the actual fix i believe is in the action handlers...

-        self.page.click(selector=selector, timeout=self.action_timeout + 20 * 1000, delay=randint(200, 500))
+        from playwright.sync_api import TimeoutError
+
+        # Trigger click and cautiously handle potential navigation
+        with self.page.expect_navigation(timeout=8000) as navigation_info:
+            self.page.click(selector=selector, timeout=self.action_timeout + 20 * 1000, delay=randint(200, 500))
+
+        try:
+            navigation_info.value  # this line blocks/waits for the navigation promise
+            logger.debug("Navigation occurred.")
+        except TimeoutError:
+            logger.debug("No navigation occurred within timeout.")
+
+#        self.page.click(selector=selector, timeout=self.action_timeout + 20 * 1000, delay=randint(200, 500))

@dgtlmoon
Copy link
Owner

dgtlmoon commented Jun 4, 2025

see #3231

@dgtlmoon dgtlmoon closed this Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants